<?php

namespace Data;

class Message extends Base {

    public function addMessage($name, $phoneNum, $content) {
        $data = array(
            'CreateTime' => time()
        );
        if(!empty($name)) {
            $data['Name'] = $name;
        }
        if(!empty($phoneNum)) {
            $data['phoneNum'] = $phoneNum;
        }
        if(!empty($content)) {
            $data['content'] = $content;
        }
        $this->insert($data);
    }

    public function getMessage($pager) {
        $this->pager($pager);
        $info = $this->findAll();
        return $info;
    }

    public function getMessageById($id) {
        $condition = array(
            'Id' => $id
        );
        $info = $this->where($condition)->findOne();
        return $info;
    }

    public function delMessageById($id) {
        $condition = array(
            'Id' => $id
        );
        $this->where($condition)->del();
    }
}